/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-30 13:41:16
 * @LastEditTime : 2023-07-04 10:57:50
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\GetAlarmLists.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AnnexButton, ExecuteButton, DelDataButton } from '../Common/options'

export const GetAlarmLists = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`getCameraGetAlarmLists`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            commonTableList.tableName,
            {
                dataIndex: 'alarmTypeName',
                title: '告警类别',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'alarmTime',
                title: '告警日期',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'deviceSerial',
                title: '设备序列号',
                valueType: 'input',
                width: 120,
            },
            {
                dataIndex: 'channelNo',
                title: '通道号',
                hideInSearch: true,
                valueType: 'input',
                width: 100,
            },
            {
                dataIndex: 'status',
                title: '状态',
                valueType: 'select',
                valueEnum: BuiltInData.status,
                width: 100,
            },

            commonTableList.BeginAlarmTime,
            commonTableList.EndAlarmTime,
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,

            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, status, gongZhongHaoAlarmUrl } = record
                    return [
                        status === 0 && (
                            <ExecuteButton
                                actionRef={actionRef}
                                key="zero"
                                title="处置"
                                url="posCameraGetUpdateAlarms"
                                path={[uuid]}
                                tips="预警信息已处理!"
                            />
                        ),
                        gongZhongHaoAlarmUrl && (
                            <AnnexButton
                                OptionsEvent={OptionsEvent}
                                key="see"
                                url={gongZhongHaoAlarmUrl}
                                title="预警画面"
                            />
                        ),
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            way="post"
                            title="删除"
                            url="posCameraGetRemoveAlarm"
                            uuid={[uuid]}
                        />,
                    ]
                },
            },
        ],
    }
    return data
}
